package ningbo.oop;

/**
 * @Author 宁铂
 * @Date 2021/7/13 10:08
 * @Version 1.0
 */
public class ReviewDemo {
    /** 本类用于回顾多态
     *  多态前提:继承+重写
     * */
    public static void main(String[] args) {
        Animal animal = new Animal();
        Cat cat = new Cat();
        Dog dog = new Dog();
        cat.jump();
        dog.rum();

        Animal animal1 = new Cat();
        Animal animal2 = new Dog();
        animal1.eat();
        animal2.eat();
    }
}

class Animal{
    public void eat(){
        System.out.println("啥都吃");
    }
}

class Cat extends Animal{
    public void eat(){
        System.out.println("吃鱼");
    }

    public void jump(){
        System.out.println("爱跳");
    }
}

class Dog extends Animal{
    public void eat(){
        System.out.println("吃肉");
    }

    public void rum(){
        System.out.println("爱跑");
    }
}